<?php

namespace App\Admin\Actions;

use App\Project;
use Encore\Admin\Actions\BatchAction;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Http\Request;
class Transfer extends BatchAction
{
    public $name = '批量切换项目';

    public function handle(Collection $collection,Request $request)
    {
        $project_id=  $request->get('project_id');
        foreach ($collection as $model) {
             $model->project_id=$project_id;
             $model->save();
        }
        return $this->response()->success('转换成功')->refresh();
    }
    public function form()
    {

        $this->select('project_id', '请选择转移的项目')->options(Project::getSelectOptions());

    }
}
